Add workflow to refresh jsonschema_for_docs.json after each release#5200
Add workflow to refresh jsonschema_for_docs.json after each release#5200shreyas-goenka merged 8 commits intomainfrom
Conversation
`bundle/internal/schema/since_version.go` reads `git tag --list 'v*'` to compute `x-since-version` annotations. The committed file therefore goes stale by one release as soon as the next tag is pushed: fields shipped in that tag don't get stamped until the schema is regenerated against a tag list that includes the new tag. The new workflow runs on every `v*` tag push (and via workflow_dispatch), regenerates the file from `main`, asserts that nothing other than `bundle/schema/jsonschema_for_docs.json` changed, and pushes the update directly to `main`. Co-authored-by: Isaac
main remains untouched. The workflow regenerates the schema in a main checkout (full history + tags so since_version.go can stamp), copies the result into a worktree on the docgen branch, and pushes there. workflow_dispatch no longer takes a tag input; it picks up the most recent v* tag automatically. Co-authored-by: Isaac
Co-authored-by: Isaac
Co-authored-by: Isaac
A branch push left GITHUB_REF starting with refs/heads/, so the strip was a no-op and the wrong value ended up in the commit message. ref_type/ref_name are unambiguous. Co-authored-by: Isaac
Co-authored-by: Isaac
janniklasrose
left a comment
There was a problem hiding this comment.
Let's add branch protection for the docgen branch?
| on: | ||
| push: | ||
| tags: | ||
| - "v*" |
There was a problem hiding this comment.
consider more scoped matching
| - "v*" | |
| - "v[0-9]+.[0-9]+.[0-9]+*" |
There was a problem hiding this comment.
Done in 6341c63. Used the suggested pattern v[0-9]+.[0-9]+.[0-9]+* for the trigger.
| if [ "$REF_TYPE" = "tag" ]; then | ||
| tag="$REF_NAME" | ||
| else | ||
| tag=$(git tag --list 'v*' --sort=-version:refname | head -n 1) |
There was a problem hiding this comment.
ditto about tag matching
There was a problem hiding this comment.
Done in 6341c63. git tag --list uses fnmatch (no +), so I match the same shape via a grep -E post-filter:
tag=$(git tag --list "v*" --sort=-version:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
Co-authored-by: Isaac
|
@janniklasrose proposed branch protection for
Equivalent JSON (for the REST API, kept here for reference): {
"name": "docgen: protected publish branch",
"target": "branch",
"enforcement": "active",
"conditions": {"ref_name": {"include": ["refs/heads/docgen"], "exclude": []}},
"rules": [
{"type": "creation"},
{"type": "deletion"},
{"type": "non_fast_forward"},
{"type": "pull_request", "parameters": {
"required_approving_review_count": 1,
"dismiss_stale_reviews_on_push": false,
"require_code_owner_review": false,
"require_last_push_approval": false,
"required_review_thread_resolution": false,
"allowed_merge_methods": ["merge", "rebase", "squash"]
}}
],
"bypass_actors": [
{"actor_id": 15368, "actor_type": "Integration", "bypass_mode": "always"}
]
}I’m applying this via the UI separately since it touches repo security config. |
|
I cannot figure out how to make github ruleset work so only the action can modify it (without creating a dedicated github app) - not worth it, lets just skip the branch protection. The worse that can happen is someone temporarily breaks the documentation generator if they accidentally write to this branch. I think it's fine without a rule protection |
Co-authored-by: Isaac
Summary
.github/workflows/update-schema-docs.ymltriggers onv*tag pushes (and manualworkflow_dispatch, which auto-detects the latestv*tag).bundle/schema/jsonschema_for_docs.jsonfrommain(full tag history is required sosince_version.gocan stampx-since-version), asserts only that file changed, and pushes the result to the dedicateddocgenbranch.mainis never modified.docgenwas bootstrapped as an orphan branch containing onlyREADME.md; the workflow addsbundle/schema/jsonschema_for_docs.jsonand updates it on every release.Why
bundle/internal/schema/since_version.goderivesx-since-versionfromgit tag --list 'v*'at generation time, so the committed file becomes stale the moment the next tag is pushed. This workflow keeps a clean publish branch (docgen) current automatically, decoupled from main.End-to-end test
Triggered the workflow via a temporary branch trigger, verified the file landed on
docgenwith up-to-date since-versions:Subsequent run (no schema change) correctly logs
docgen already up to date for v0.299.0; nothing to commit.